package com.wing.user.service;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.alibaba.spring.util.ObjectUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wing.common.utils.JsonResult;
import com.wing.user.model.entity.WareHouseCustomerVo;
import lombok.val;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wing.user.dao.WarehouseCustomerDao;
import com.wing.user.model.entity.WarehouseCustomer;
import com.wing.user.service.WarehouseCustomerService;
@Service
public class WarehouseCustomerServiceImpl extends ServiceImpl<WarehouseCustomerDao, WarehouseCustomer> implements WarehouseCustomerService{

    @Override
    public Page<WareHouseCustomerVo> pageList4app(Page<WareHouseCustomerVo> pg, Map paramMap) {
        return baseMapper.pageList4app(pg, paramMap);
    }

    @Override
    public int add (WarehouseCustomer warehouseCustomer){
        if (ObjectUtil.isNotEmpty(warehouseCustomer)){
            return baseMapper.insert(warehouseCustomer);
        }else {
            return 0;
        }
    }

    @Override
    public JsonResult updateWarehouseCustomer (WarehouseCustomer warehouseCustomer){
        JsonResult jsonResult = new JsonResult<>();
        if (warehouseCustomer.getId() != null){
            baseMapper.updateById(warehouseCustomer);
            return jsonResult.success("修改成功");
        }else {
           return jsonResult.fail("修改失败");
        }
    }

    @Override
    public JsonResult deleteWarehouseCustomer (Long warehouseCustomerId){
        JsonResult jsonResult = new JsonResult<>();
        if (warehouseCustomerId != null){
            WarehouseCustomer warehouseCustomer = this.getById(warehouseCustomerId);
            warehouseCustomer.setIsDeleted(true);
            this.updateById(warehouseCustomer);
            return jsonResult.success("删除成功");
        }else {
            return jsonResult.fail("删除失败");
        }
    }
}
